<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="java," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="关于http get和post请求调用代码以及示例。参考:http://www.cnblogs.com/zhuawang/archive/2012/12/08/2809380.html http请求代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535">
<meta name="keywords" content="java">
<meta property="og:type" content="article">
<meta property="og:title" content="Java http请求和调用">
<meta property="og:url" content="http://yoursite.com/2017/05/27/pancm25/index.html">
<meta property="og:site_name" content="虚无境的博客">
<meta property="og:description" content="关于http get和post请求调用代码以及示例。参考:http://www.cnblogs.com/zhuawang/archive/2012/12/08/2809380.html http请求代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535">
<meta property="og:image" content="http://img.blog.csdn.net/20170527112538021?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWF6d3N4cGNt/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:updated_time" content="2017-12-16T10:47:28.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Java http请求和调用">
<meta name="twitter:description" content="关于http get和post请求调用代码以及示例。参考:http://www.cnblogs.com/zhuawang/archive/2012/12/08/2809380.html http请求代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535">
<meta name="twitter:image" content="http://img.blog.csdn.net/20170527112538021?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWF6d3N4cGNt/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/05/27/pancm25/"/>






  <title>Java http请求和调用 | 虚无境的博客</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?39c177d10f6e05ddfa113e02139b9c1c";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">虚无境的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/27/pancm25/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="虚无境">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/xuwujing.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="虚无境的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Java http请求和调用</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-27T11:39:00+08:00">
                2017-05-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index">
                    <span itemprop="name">java</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <script src="\assets\js\APlayer.min.js"> </script><p>关于http get和post请求调用代码以及示例。<br>参考:<a href="http://www.cnblogs.com/zhuawang/archive/2012/12/08/2809380.html" target="_blank" rel="external">http://www.cnblogs.com/zhuawang/archive/2012/12/08/2809380.html</a></p>
<h2 id="http请求代码"><a href="#http请求代码" class="headerlink" title="http请求代码"></a>http请求代码</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div></pre></td><td class="code"><pre><div class="line">import java.io.BufferedReader;</div><div class="line">import java.io.IOException;</div><div class="line">import java.io.InputStreamReader;</div><div class="line">import java.io.PrintWriter;</div><div class="line">import java.net.URL;</div><div class="line">import java.net.URLConnection;</div><div class="line">import java.util.HashMap;</div><div class="line">import java.util.Iterator;</div><div class="line">import java.util.Map;</div><div class="line">import java.util.Map.Entry;</div><div class="line"></div><div class="line">/**</div><div class="line"> * @author xuwujing</div><div class="line"> * @Data 2016-6-13 上午11:57:52</div><div class="line"> * @Description  http请求工具类</div><div class="line"> */</div><div class="line">public class MyHttpRequest &#123;</div><div class="line">   </div><div class="line">	/**</div><div class="line">     * 向指定URL发送GET方法的请求</div><div class="line">     * </div><div class="line">     * @param url</div><div class="line">     *            发送请求的URL</div><div class="line">     * @param param</div><div class="line">     *            请求Map参数，请求参数应该是 &#123;&quot;name1&quot;:&quot;value1&quot;,&quot;name2&quot;:&quot;value2&quot;&#125;的形式。</div><div class="line">     * @param charset         </div><div class="line">     * 			   发送和接收的格式</div><div class="line">     * @return URL 所代表远程资源的响应结果</div><div class="line">     */</div><div class="line">	public static String sendGet(String url, Map&lt;String,Object&gt; map,String charset)&#123;</div><div class="line">		  StringBuffer sb=new StringBuffer();</div><div class="line">		  //构建请求参数</div><div class="line">		  if(map!=null&amp;&amp;map.size()&gt;0)&#123;</div><div class="line">			  Iterator it=map.entrySet().iterator(); //定义迭代器</div><div class="line">			  while(it.hasNext())&#123;</div><div class="line">				 Map.Entry  er= (Entry) it.next();</div><div class="line">				 sb.append(er.getKey());</div><div class="line">				 sb.append(&quot;=&quot;);</div><div class="line">				 sb.append(er.getValue());</div><div class="line">				 sb.append(&quot;&amp;&quot;);</div><div class="line">			 &#125;</div><div class="line">		  &#125;</div><div class="line">	   return  sendGet(url,sb.toString(), charset);</div><div class="line">	&#125;</div><div class="line">	</div><div class="line">	</div><div class="line">	/**</div><div class="line">     * 向指定URL发送POST方法的请求</div><div class="line">     * </div><div class="line">     * @param url</div><div class="line">     *            发送请求的URL</div><div class="line">     * @param param</div><div class="line">     *            请求Map参数，请求参数应该是 &#123;&quot;name1&quot;:&quot;value1&quot;,&quot;name2&quot;:&quot;value2&quot;&#125;的形式。</div><div class="line">     * @param charset         </div><div class="line">     * 			   发送和接收的格式</div><div class="line">     * @return URL 所代表远程资源的响应结果</div><div class="line">     */</div><div class="line">	public static String sendPost(String url, Map&lt;String,Object&gt; map,String charset)&#123;</div><div class="line">		  StringBuffer sb=new StringBuffer();</div><div class="line">		  //构建请求参数</div><div class="line">		  if(map!=null&amp;&amp;map.size()&gt;0)&#123;</div><div class="line">	            for (Entry&lt;String, Object&gt; e : map.entrySet()) &#123;  </div><div class="line">	            	sb.append(e.getKey());  </div><div class="line">	            	sb.append(&quot;=&quot;);  </div><div class="line">	            	sb.append(e.getValue());  </div><div class="line">	            	sb.append(&quot;&amp;&quot;);  </div><div class="line">	            &#125;  </div><div class="line">		  &#125;</div><div class="line">	   return  sendPost(url,sb.toString(),charset);</div><div class="line">	&#125;</div><div class="line">	</div><div class="line">	</div><div class="line">	/**</div><div class="line">     * 向指定URL发送GET方法的请求</div><div class="line">     * </div><div class="line">     * @param url</div><div class="line">     *            发送请求的URL</div><div class="line">     * @param param</div><div class="line">     *            请求参数，请求参数应该是 name1=value1&amp;name2=value2 的形式。</div><div class="line">     * @param charset         </div><div class="line">     * 			   发送和接收的格式</div><div class="line">     * @return URL 所代表远程资源的响应结果</div><div class="line">     */</div><div class="line">    public static String sendGet(String url, String param,String charset) &#123;</div><div class="line">        String result = &quot;&quot;;</div><div class="line">        String line;</div><div class="line">        StringBuffer sb=new StringBuffer();</div><div class="line">        BufferedReader in = null;</div><div class="line">        try &#123;</div><div class="line">            String urlNameString = url + &quot;?&quot; + param;</div><div class="line">            URL realUrl = new URL(urlNameString);</div><div class="line">            // 打开和URL之间的连接</div><div class="line">            URLConnection conn = realUrl.openConnection();</div><div class="line">            // 设置通用的请求属性 设置请求格式</div><div class="line">            conn.setRequestProperty(&quot;contentType&quot;, charset); </div><div class="line">            conn.setRequestProperty(&quot;content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);</div><div class="line">            //设置超时时间</div><div class="line">            conn.setConnectTimeout(60);</div><div class="line">            conn.setReadTimeout(60);</div><div class="line">            // 建立实际的连接</div><div class="line">            conn.connect();</div><div class="line">            // 定义 BufferedReader输入流来读取URL的响应,设置接收格式</div><div class="line">            in = new BufferedReader(new InputStreamReader(</div><div class="line">            		conn.getInputStream(),charset));</div><div class="line">            while ((line = in.readLine()) != null) &#123;</div><div class="line">            	sb.append(line);</div><div class="line">            &#125;</div><div class="line">            result=sb.toString();</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            System.out.println(&quot;发送GET请求出现异常！&quot; + e);</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        // 使用finally块来关闭输入流</div><div class="line">        finally &#123;</div><div class="line">            try &#123;</div><div class="line">                if (in != null) &#123;</div><div class="line">                    in.close();</div><div class="line">                &#125;</div><div class="line">            &#125; catch (Exception e2) &#123;</div><div class="line">                e2.printStackTrace();</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        return result;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    /**</div><div class="line">     * 向指定 URL 发送POST方法的请求</div><div class="line">     * </div><div class="line">     * @param url</div><div class="line">     *            发送请求的 URL</div><div class="line">     * @param param</div><div class="line">     *            请求参数，请求参数应该是 name1=value1&amp;name2=value2 的形式。</div><div class="line">     * @param charset         </div><div class="line">     * 			   发送和接收的格式       </div><div class="line">     * @return 所代表远程资源的响应结果</div><div class="line">     */</div><div class="line">    public static String sendPost(String url, String param,String charset) &#123;</div><div class="line">        PrintWriter out = null;</div><div class="line">        BufferedReader in = null;</div><div class="line">        String result = &quot;&quot;;</div><div class="line">        String line;</div><div class="line">        StringBuffer sb=new StringBuffer();</div><div class="line">        try &#123;</div><div class="line">            URL realUrl = new URL(url);</div><div class="line">            // 打开和URL之间的连接 </div><div class="line">            URLConnection conn = realUrl.openConnection();</div><div class="line">            // 设置通用的请求属性 设置请求格式</div><div class="line">            conn.setRequestProperty(&quot;contentType&quot;, charset);  </div><div class="line">            conn.setRequestProperty(&quot;content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);</div><div class="line">            //设置超时时间</div><div class="line">            conn.setConnectTimeout(60);</div><div class="line">            conn.setReadTimeout(60);</div><div class="line">            // 发送POST请求必须设置如下两行</div><div class="line">            conn.setDoOutput(true);</div><div class="line">            conn.setDoInput(true);</div><div class="line">            // 获取URLConnection对象对应的输出流</div><div class="line">            out = new PrintWriter(conn.getOutputStream());</div><div class="line">            // 发送请求参数</div><div class="line">            out.print(param);</div><div class="line">            // flush输出流的缓冲</div><div class="line">            out.flush();</div><div class="line">            // 定义BufferedReader输入流来读取URL的响应    设置接收格式</div><div class="line">            in = new BufferedReader(</div><div class="line">                    new InputStreamReader(conn.getInputStream(),charset));</div><div class="line">            while ((line = in.readLine()) != null) &#123;</div><div class="line">            	sb.append(line);</div><div class="line">            &#125;</div><div class="line">            result=sb.toString();</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            System.out.println(&quot;发送 POST请求出现异常!&quot;+e);</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        //使用finally块来关闭输出流、输入流</div><div class="line">        finally&#123;</div><div class="line">            try&#123;</div><div class="line">                if(out!=null)&#123;</div><div class="line">                    out.close();</div><div class="line">                &#125;</div><div class="line">                if(in!=null)&#123;</div><div class="line">                    in.close();</div><div class="line">                &#125;</div><div class="line">            &#125;</div><div class="line">            catch(IOException ex)&#123;</div><div class="line">                ex.printStackTrace();</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        return result;</div><div class="line">    &#125;</div></pre></td></tr></table></figure>
<h2 id="调用方法"><a href="#调用方法" class="headerlink" title="调用方法"></a>调用方法</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">  public static void main(String[] args) &#123;</div><div class="line">	String getUrl=&quot;http://int.dpool.sina.com.cn/iplookup/iplookup.php&quot;;</div><div class="line">	String postUrl=&quot;http://gc.ditu.aliyun.com/geocoding&quot;;</div><div class="line">	String param=&quot;format=json&amp;ip=218.4.255.255&quot;;</div><div class="line">	String param1=&quot;a=苏州市&quot;;</div><div class="line">	Map&lt;String,Object&gt; map=new HashMap&lt;String,Object&gt;();</div><div class="line">	map.put(&quot;format&quot;, &quot;json&quot;);</div><div class="line">	map.put(&quot;ip&quot;, &quot;218.4.255.255&quot;);</div><div class="line">	Map&lt;String,Object&gt; map1=new HashMap&lt;String,Object&gt;();</div><div class="line">	map1.put(&quot;a&quot;, &quot;苏州市&quot;);</div><div class="line">	System.out.println(&quot;Get请求1:&quot;+MyHttpRequest.sendGet(getUrl, param,&quot;utf-8&quot;));</div><div class="line">	System.out.println(&quot;Get请求2:&quot;+MyHttpRequest.sendGet(getUrl, map,&quot;utf-8&quot;));</div><div class="line">	System.out.println(&quot;Post请求1:&quot;+MyHttpRequest.sendPost(postUrl, param1,&quot;utf-8&quot;));</div><div class="line">	System.out.println(&quot;Post请求2:&quot;+MyHttpRequest.sendPost(postUrl, map,&quot;utf-8&quot;));</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><strong>返回结果</strong><br><img src="http://img.blog.csdn.net/20170527112538021?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWF6d3N4cGNt/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
<p>版权声明:<br>作者：虚无境<br>博客园出处：<a href="http://www.cnblogs.com/xuwujing" target="_blank" rel="external">http://www.cnblogs.com/xuwujing</a><br>CSDN出处：<a href="http://blog.csdn.net/qazwsxpcm" target="_blank" rel="external">http://blog.csdn.net/qazwsxpcm</a>　　　　<br>个人博客出处：<a href="http://www.panchengming.com" target="_blank" rel="external">http://www.panchengming.com</a><br>原创不易，转载请标明出处，谢谢！</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>
     
    <div>
	 +
	  
<div style="text-align:center;color: #ccc;font-size:14px;">
------ 本文结束 ------</div>
<br/>
<div style="border: 1px solid black">
<div style="margin-left:10px">
<span style="font-weight:blod">版权声明</span>
<!-- <img src="/images/xuwujing.png" > -->
<br/>
<p style="font-size: 10px;line-height: 30px"><a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> by <a href="http://www.panchengming.com/" style="color:#258FC6">ChengMing Pan</a> is licensed under a <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">Creative Commons BY-NC-ND 4.0 International License</a>.<br/>
由<a href="http://www.panchengming.com/" style="color:#258FC6">虚无境</a>创作并维护的<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a>博客采用<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">创作共用保留署名-非商业-禁止演绎4.0国际许可证</a>。<br/>
本文首发于<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> 博客（ <a href="http://www.panchengming.com/" style="color:#258FC6">http://www.panchengming.com/</a> ），版权所有，侵权必究。</p>
</div>
</div>

	
	</div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/java/" rel="tag"># java</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/05/23/pancm24/" rel="next" title="Spring连接池的常用配置（转）">
                <i class="fa fa-chevron-left"></i> Spring连接池的常用配置（转）
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/29/pancm26/" rel="prev" title="SQL 常用语法一">
                SQL 常用语法一 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/xuwujing.png"
               alt="虚无境" />
          <p class="site-author-name" itemprop="name">虚无境</p>
           
              <p class="site-description motion-element" itemprop="description">The way of the future!</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">136</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">30</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">59</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/xuwujing" target="_blank" title="github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  github
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://blog.csdn.net/qazwsxpcm?viewmode=list" target="_blank" title="csdn">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  csdn
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://home.cnblogs.com/u/xuwujing/" target="_blank" title="cnblogs">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  cnblogs
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.woainia.site/" title="woainia" target="_blank">woainia</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://cmsblogs.com/" title="chenssy" target="_blank">chenssy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://italker.imisty.cn" title="xiaowu" target="_blank">xiaowu</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#http请求代码"><span class="nav-number">1.</span> <span class="nav-text">http请求代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#调用方法"><span class="nav-number">2.</span> <span class="nav-text">调用方法</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">虚无境</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
 | 
本站总访问量<span id="busuanzi_value_site_pv"></span>次
 | 
本站访客数<span id="busuanzi_value_site_uv"></span>人次
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=857896&auto=0&height=66"></iframe>



        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
